<template>
  <div>
        <el-menu
            style="width: 200px;min-height: calc(100vh - 50px)"
            router
            :default-active="path"
            class="el-menu-vertical-demo"
        >
          <el-menu-item index="/home" v-if="user.roleId==1">
            <el-icon><grid /></el-icon>
            <span>销售统计</span>
          </el-menu-item>

          <el-sub-menu index="system" v-if="user.roleId==1">
            <template #title>
              <el-icon><location /></el-icon>
              <span>用户管理</span>
            </template>
              <el-menu-item index="/system-user">管理员管理</el-menu-item>
            <el-menu-item index="/system-frontUser">客户管理</el-menu-item>
          </el-sub-menu>
          <el-menu-item index="/foodType" v-if="user.roleId==1">
            <el-icon><grid /></el-icon>
            <span>菜品类别管理</span>
          </el-menu-item>
          <el-menu-item index="/food">
            <el-icon><food /></el-icon>
            <span>菜品管理</span>
          </el-menu-item>
          <el-menu-item index="/order">
            <el-icon><food /></el-icon>
            <span>订单管理</span>
          </el-menu-item>
          <el-menu-item index="/role" v-if="user.roleId==1">
            <el-icon><food /></el-icon>
            <span>角色管理</span>
          </el-menu-item>
          <el-menu-item index="/vip" v-if="user.roleId==1">
            <el-icon><food /></el-icon>
            <span>会员等级管理</span>
          </el-menu-item>
        </el-menu>
  </div>
</template>



<script>
import {Document, Location, Menu, Setting,Food,Grid} from "@element-plus/icons";
import request from "@/utils/request";

export default {
  components: {
    Location, Setting, Menu ,Document,Food,Grid
  },
  name: "Aside.vue",
  data() {
    return {
      path: this.$route.path,
      user: ''
    }
  },
  created() {
    this.updateUser();
  },
  methods: {
    updateUser() {
      //更新一下最新数据
      let userJson = sessionStorage.getItem("user") || "{}"
      if(userJson){
        let user = JSON.parse(userJson)
        request.get("order/admin/getUserById",{params:{id:user.id}}).then((res) =>{
          this.user=res.data
        })
      }else{
        this.$message.error("业务员服务异常!");
        return
      }
    },
  }
}
</script>

<style scoped>

</style>



